package com.ssy.lingxi.product.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 订单会员商品已售实体类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/9/4
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_order_commodity_sold", indexes = {@Index(name = "product_order_commodity_sold_shop_id_idx", columnList = "shopId")})
public class OrderCommoditySold implements Serializable {
    private static final long serialVersionUID = 7565701756623347526L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="order_commodity_sold_seq")
    @SequenceGenerator(sequenceName="product_order_commodity_sold_seq", name="order_commodity_sold_seq",allocationSize = 1)
    private Long id;

    /**
     * 订单商品
     */
    @JsonIgnore
    @ManyToOne(cascade={CascadeType.PERSIST})
    @JoinColumn(name="orderCommodityId",referencedColumnName = "id")
    private OrderCommodity orderCommodity;

    /**
     * 商城id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long shopId;

    /**
     * 已售数量
     */
    @Column(columnDefinition = "decimal", nullable = false)
    private Double sold;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long createTime = System.currentTimeMillis();
}
